﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Advertising.Mobile.UI;
using Common.Library;
using OnlineVideos.UI;
using OnlineVideos.Common;
using Common.Utilities;

namespace OnlineVideos.Views
{
    public partial class BackAgentError : PhoneApplicationPage
    {
        #region Constructor
        public BackAgentError()
        {
            InitializeComponent();
            Loaded += new RoutedEventHandler(BackAgentError_Loaded);
        }
        #endregion
        protected override void OnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e)
        {
            FlurryWP8SDK.Api.EndTimedEvent("BackAgentError Page");
        }
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            FlurryWP8SDK.Api.LogPageView();
        }
        #region PageLoad
        void BackAgentError_Loaded(object sender, RoutedEventArgs e)
        {
            LoadAds();
            FlurryWP8SDK.Api.LogEvent("BackAgentError Page", true);
            string backgroundAgentError = AppSettings.BackgroundAgenError;
          
            if (!string.IsNullOrEmpty(backgroundAgentError))
                TbError.Text = backgroundAgentError;
            else
            {
                NoError.Visibility = Visibility.Visible;
                NoError.Text = "No errors in background agent.";
            }
        }
        private void LoadAds()
        {
            try
            {
                PageHelper.LoadAdControl(LayoutRoot, adstackpl, 2);
            }
            catch (Exception ex)
            {
                Exceptions.SaveOrSendExceptions("Exception in LoadAds Method In SongDetails file", ex);
                string excepmess = "Exception in LoadAds Method In SongDetails file.\n\n" + ex.Message + "\n\n StackTrace :- \n" + ex.StackTrace;
            }
        }
        #endregion

        #region Events
        private void imgTitle_MouseEnter(object sender, MouseButtonEventArgs e)
        {
            NavigationService.Navigate(NavigationHelper.MainPanoramaPage);
        }
        #endregion
        private void btnmusic_click(object sender, EventArgs e)
        {
            NavigationService.Navigate(new Uri("/Views/MusicSettings.xaml",UriKind.Relative));
        }
    }
}